using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace OpenProject.Web
{
    public class UrlUtilities
    {
        protected static string _baseUrl = "~/";
        protected static string BaseUrl
        {
            get
            {
                return VirtualPathUtility.ToAbsolute(_baseUrl);
            }
        }
        protected static string UrlEncode(string value)
        {
            if (HttpContext.Current != null)
                value = HttpContext.Current.Server.UrlEncode(value);
            return value;
        }
        /// <summary>
        /// return the home page url for the specified project
        /// </summary>
        /// <param name="projectTitle"></param>
        /// <returns></returns>
        public static string ProjectUrl(string projectTitle)
        {
            return BaseUrl + "projects/" + UrlEncode(projectTitle);
        }
        /// <summary>
        /// Return the home page url for the current project
        /// </summary>
        /// <returns></returns>
        public static string ProjectUrl()
        {
            return ProjectUrl(SiteUtilities.ProjectTitle);
        }
        public static string WorkItemUrl(string projectTitle, string workItemId)
        {
            return ProjectUrl(projectTitle) + "/workItem" + workItemId; 
        }
        public static string PageUrl(string projectTitle, string pageUrl)
        {
            return ProjectUrl(projectTitle) + "/pages/" + UrlEncode(pageUrl);
        }
    }

}
